package com.bjc.principle.proxy.demo4;

import com.bjc.principle.proxy.demo2.UserService;
import com.bjc.principle.proxy.demo2.UserServiceImpl;

/**
 * @program: DesignPattern
 * @description:
 * @author: bjc
 * @create: 2020-12-28 20:36
 */
public class Client {

    public static void main(String[] args) {
        //真实角色
        UserServiceImpl userService = new UserServiceImpl();
        //代理角色，不存在
        ProxyInvocationHandler handler = new ProxyInvocationHandler();
        //设置需要代理的对象
        handler.setTarget(userService);
        //动态生成代理类
        UserService proxy =(UserService) handler.getProxy();
        proxy.add();
    }
}
